//
//  array_sort.hpp
//  suanfa
//
//  Created by 李贺 on 2021/11/24.
//

#ifndef array_sort_hpp
#define array_sort_hpp

#include <stdio.h>
#include <vector>
#include <iostream>


using namespace std;

class Solution_array_sort {

public:
    vector<int> sortedSequence(vector<int> &nums) {
        for (int index = 0; index < nums.size(); index++) {
            nums[index] = nums[index] * nums[index];
        }
        sort(nums.begin(), nums.end());
        return nums;
    }
    
    vector<int> sortedSequence1(vector<int> &nums) {
        for (int index = 0; index < nums.size(); index++) {
            nums[index] = nums[index] * nums[index];
        }
        
        for (int index = 0; index < nums.size(); index++) {
            int first = nums[index];
            for (int j = index + 1; j < nums.size(); j++) {
                if (first > nums[j]) {
                    nums[index] = nums[j];
                    nums[j] = first;
                }
            }
        }
            
        return nums;
    }
    
    
    void test() {
        vector<int> nums;
        nums.push_back(-1);
        nums.push_back(-2);
        nums.push_back(0);
        nums.push_back(88);
        nums.push_back(66);
        vector<int> resutl = this->sortedSequence1(nums);
        
        for (int index = 0; index < resutl.size(); index++) {
            cout << "result" << resutl[index] << "\n";
        }
        
    }
};

#endif /* array_sort_hpp */
